package com.yinp.proapp.module.customview.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.yinp.proapp.R;
import com.yinp.proapp.module.customview.bean.CustomViewBean;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @author :yinpeng
 * date      :2022/1/10
 * package   :com.yinp.proapp.module.customview.adapter
 * describe  :
 */
public class CustomViewAdapter extends BaseMultiItemQuickAdapter<CustomViewBean, BaseViewHolder> {
    public CustomViewAdapter(List<CustomViewBean> data) {
        super(data);
        addItemType(CustomViewBean.Text, R.layout.item_custom_view_text);
        addItemType(CustomViewBean.MeView, R.layout.item_custom_view_me);
        addItemType(CustomViewBean.OtherView, R.layout.item_custom_view_other);
        addItemType(CustomViewBean.MixedView, R.layout.item_custom_view_mixed);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, CustomViewBean customViewBean) {
        baseViewHolder.setText(R.id.tv_title, customViewBean.getTitle());
        switch (customViewBean.getItemType()) {
            case CustomViewBean.OtherView:
                baseViewHolder.setText(R.id.tv_introduce, customViewBean.getIntroduce());
                break;
            case CustomViewBean.MeView:
                //暂时屏蔽
                baseViewHolder.getView(R.id.stvThink).setVisibility(View.GONE);
                addChildClickViewIds(R.id.stvThink);
                break;
        }
    }
}
